package com.woniuxy.sys.service.impl;

import cn.hutool.json.JSONUtil;
import com.woniuxy.sys.entity.StoreInfo;
import com.woniuxy.sys.mapper.StoreInfoMapper;
import com.woniuxy.sys.service.IStoreInfoService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author Lzj
 * @since 2023-11-02
 */
@Service
public class StoreInfoServiceImpl extends ServiceImpl<StoreInfoMapper, StoreInfo> implements IStoreInfoService {

    @Autowired
    private RabbitTemplate rabbitTemplate;

    @Override
    public String addStore(StoreInfo storeInfo) {
        baseMapper.insert(storeInfo);
        rabbitTemplate.convertAndSend("exchange-store","store.add", JSONUtil.toJsonStr(storeInfo));
        return "ok";
    }
}
